<template>
	<view class="content">
		<view class="top_content">
			<view class="in_content">
				<view class="title">
					<view class="title_icon">
						<u-icon name="photo"></u-icon>
						<view>我的</view>
					</view>
					<view class="set">收款设置</view>
				</view>

				<view class="centent_num">
					<view class="text">
						<view class="text_num blue">50.98</view>
						<view class="text_color">可兑换</view>
					</view>

					<view class="line"></view>

					<view class="text">
						<view class="text_num red">50.98</view>
						<view class="text_color">不可兑换</view>
					</view>
				</view>

				<view class="line"></view>

				<view class="footer_text">
					<u-icon name="question-circle"></u-icon>
					<view>兑换规则</view>
				</view>
			</view>
			
			<view class="input_num">
				<view>兑换</view>
				<view class="input">
					<u-input  border="false" placeholder="请输入兑换数量" placeholderStyle="font-size: 24rpx" />
				</view>
				<view class="all">全部</view>
				<view class="btn_bgc">兑换</view>
			</view>
		</view>

		<view class="center_content">
			<view class="line"></view>
			<view class="title">
				<u-icon name="photo"></u-icon>
				<view>兑换记录</view>
			</view>
			<view class="line"></view>

			<view class="recording">
				<view class="item" v-for="(item, index) in sliceList" :key="index">
				<view>时间：{{ item.time }}</view>
				<view>数量：{{ item.num }}</view>
				<view>状态：{{ item.state }}</view>
			</view>
			</view>
		</view>

		<view class="footer_content">
			<view @click="handlePre">上一页</view>
			<view @click="handleNext">下一页</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			recordingList: [
				{
					time: '09-21 22:12:00',
					num: 1,
					state: '已到'
				},
				{
					time: '09-21 22:12:00',
					num: 2,
					state: '已到'
				},
				{
					time: '09-21 22:12:00',
					num: 3,
					state: '已到'
				},
				{
					time: '09-21 22:12:00',
					num: 4,
					state: '已到'
				},
				{
					time: '09-21 22:12:00',
					num: 5,
					state: '已到'
				},
				{
					time: '09-21 22:12:00',
					num: 6,
					state: '已到'
				},
				{
					time: '09-21 22:12:00',
					num: 7,
					state: '已到'
				},

			],
			sliceList: [],
			curPage: 1, // 当前第几页
			pageSize: 2, // 每页 2 条数据
		}
	},
	onLoad() {
		this.sliceList = this.recordingList.slice(0, this.pageSize);
	},
	methods: {
		handlePre() { // 上一条
			if(this.curPage > 0) {
				--this.curPage
				this.sliceList = this.recordingList.slice( this.curPage * this.pageSize  , (this.curPage * this.pageSize) + this.pageSize )
			}
			
		},
		handleNext() { // 下一条
			let total = Math.floor(this.recordingList.length / this.pageSize)
			if (this.curPage < total) {
				++this.curPage
				this.sliceList = this.recordingList.slice( this.curPage * this.pageSize  , (this.curPage * this.pageSize) + this.pageSize )
			}
		}
	}
}
</script>

<style scoped lang="scss">
.content {
	padding: 20rpx;

	.top_content {
		/* border: 2rpx solid red; */
		/* padding: 10rpx 0; */
		padding-bottom: 20rpx;
		border-radius: 20rpx;
		box-shadow: 0rpx 8rpx 20rpx #e9e5e5;
		background-color: #febd03;

		.in_content {
			background-color: #fff;
			border-radius: 20rpx;

			.title {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 30rpx 30rpx;

				.title_icon {
					display: flex;
					align-items: center;

					view {
						margin-left: 10rpx;
						font-weight: 600;
					}
				}

				.set {
					font-size: 24rpx;
					color: #84888d;
				}
			}

			.centent_num {
				display: flex;
				justify-content: space-around;

				.text {
					display: flex;
					flex-direction: column;
					align-items: center;

					.text_num {
						font-size: 48rpx;
						font-weight: 600;
					}

					.blue {
						color: #086ef9;
					}

					.red {
						color: red;
					}

					.text_color {
						margin-right: 10rpx;
						font-size: 24rpx;
						color: #7a8084;
					}
				}

				.line {
					height: 80rpx;
					width: 2rpx;
					background-color: #dfdfdf;
				}
			}

			.line {
				margin: 20rpx 0;
				height: 2rpx;
				background-color: #f1f1f1;
			}

			.footer_text {
				display: flex;
				justify-content: center;
				align-items: center;
				padding-bottom: 20rpx;
				color: #7b7e81;
				font-size: 24rpx;
				view {
					margin-left: 10rpx;
				}
			}
		}

		.input_num {
			display: flex;
			justify-content: space-around;
			align-items: center;
			border-radius: 30rpx;
			background-color: #fff;
			margin: 20rpx 30rpx 0;
			font-size: 24rpx;

			.input {
				width: 280rpx;
			}
			.all {
				color: #23c9e7;
				font-weight: 600;
			}
			.btn_bgc {
				background-color: #0472fd;
				color: #fff;
				padding: 10rpx 20rpx;
				border-radius: 30rpx;
			}
		}
	}

	.center_content {
		margin-top: 70rpx;
		.line {
			margin: 30rpx 0;
			height: 2rpx;
			background-color: #e9e9e9;
		}

		.title {
			display: flex;
			align-items: center;

			view {
				margin-left: 10rpx;
				font-size: 24rpx;
			}
		}

		.recording {
			background-color: #f9fafc;
			padding: 20rpx 30rpx;
			.item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 24rpx;
				margin-bottom: 10rpx;
			}
		}
	}
	
	.footer_content {
		margin-top: 40rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		font-size: 24rpx;
		color: #498fe6;
		

		view {
			padding: 10rpx 20rpx;
		}
		view:nth-child(1) {
			border: 2rpx solid #498fe6;
			border-bottom-left-radius: 20rpx;
			border-top-left-radius: 20rpx;
		}
		view:nth-child(2) {
			border: 2rpx solid #498fe6;
			border-bottom-right-radius: 20rpx;
			border-top-right-radius: 20rpx;
		}
	}
}</style>
